package com.controller;

import com.alipay.api.AlipayApiException;
import com.config.RequestAliPay;
import com.service.IAliPayService;
import com.utils.R;
import com.utils.ZhifubaoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @Author Ms.发发
 * @ClassName AliPayController
 * @Date 2024/12/18 20:40
 * @Description
 **/
@RestController
@RequestMapping("/alipay")
@Slf4j
public class AliPayController {

    @Autowired
    private IAliPayService aliPayService;


    /***
     * 支付
     * @param requestAliPay
     * @return
     * @throws AlipayApiException
     */
    @PostMapping()
    public R aliPay(@RequestBody RequestAliPay requestAliPay) throws AlipayApiException {
        //下单
        return R.ok(aliPayService.aliPay(requestAliPay));
    }


    /***
     * 查询订单
     * @param tradeNo
     * @return
     * @throws AlipayApiException
     */
    @GetMapping
    public void selectOrder(@RequestParam(name = "tradeNo") String tradeNo) throws AlipayApiException {
        ZhifubaoUtil.queryResult(tradeNo);
    }
}
